package mju.cxf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import mju.cxf.dto.CreditDTO;
import mju.cxf.entity.Credit;
import mju.cxf.entity.Credit;
import mju.cxf.mapper.CreditMapper;
import mju.cxf.mapper.CreditMapper;
import mju.cxf.service.CreditService;
import mju.cxf.service.CreditService;
import mju.cxf.utils.TimestampUpdaterUtils;
import mju.cxf.vo.CreditVO;
import mju.cxf.vo.CreditVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * <p>
 * 信用分表 服务实现类
 * </p>
 *
 * @author 郑献
 * @since 2024-10-23
 */

@Service
public class CreditServiceImpl extends ServiceImpl<CreditMapper, Credit> implements CreditService {
    /**
     * A分页查询信用分信息
     * @param score
     * @return
     */
    @Override
    public Page<CreditVO> selectPage(Integer score, Integer status,int current, int size) {
        Page<CreditVO> page = new Page<>(current, size);
        return this.baseMapper.selectPageVo(page,score, status);
    }

    /**
     * A删除信用分信息
     * @param id
     * @return
     */
    @Override
    public boolean deleteCredit(Integer id) {
        return this.removeById(id);
    }

    /**
     * A修改信用分信息
     * @param creditDTO
     * @return
     */
    @Override
    public boolean updateCredit(CreditDTO creditDTO) {
        Credit credit = new Credit();
        BeanUtils.copyProperties(creditDTO,credit);
        return this.updateById(credit);
    }

    /**
     * A新增信用分信息
     * @param creditDTO
     * @return
     */
    @Override
    public boolean saveCredit(CreditDTO creditDTO) {
        Credit credit = new Credit();
        BeanUtils.copyProperties(creditDTO, credit);
        return this.save(credit); // 使用 MyBatis-Plus 提供的 save() 方法
    }
}
